<pre style="line-height: 100%;font-family:monospace;background-color:#ffffff; border-width:0.01mm; border-color:#000000; border-style:solid;padding:4px;font-size:10pt;"><span style="color:#808080;background-color:#ffffff;">/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
</span><span style="color:#000080;background-color:#ffffff;">package</span><span style="background-color:#ffffff;"> cal;

</span><span style="color:#000080;background-color:#ffffff;">import</span><span style="background-color:#ffffff;"> javax.servlet.http.*;
</span><span style="color:#000080;background-color:#ffffff;">import</span><span style="background-color:#ffffff;"> java.util.Hashtable;

</span><span style="color:#000080;background-color:#ffffff;">public</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">class</span><span style="background-color:#ffffff;"> TableBean {

  Hashtable </span><span style="color:#660e7a;background-color:#ffffff;">table;
</span><span style="background-color:#ffffff;">  JspCalendar JspCal;
  Entries entries;
  String </span><span style="color:#660e7a;background-color:#ffffff;">date;
</span><span style="background-color:#ffffff;">  String </span><span style="color:#660e7a;background-color:#ffffff;">name </span><span style="background-color:#ffffff;">= </span><span style="color:#000080;background-color:#ffffff;">null</span><span style="background-color:#ffffff;">;
  String </span><span style="color:#660e7a;background-color:#ffffff;">email </span><span style="background-color:#ffffff;">= </span><span style="color:#000080;background-color:#ffffff;">null</span><span style="background-color:#ffffff;">;
  </span><span style="color:#000080;background-color:#ffffff;">boolean</span><span style="background-color:#ffffff;"> </span><span style="color:#660e7a;background-color:#ffffff;">processError </span><span style="background-color:#ffffff;">= </span><span style="color:#000080;background-color:#ffffff;">false</span><span style="background-color:#ffffff;">;

  </span><span style="color:#000080;background-color:#ffffff;">public</span><span style="background-color:#ffffff;"> TableBean () {
    </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">table </span><span style="background-color:#ffffff;">= </span><span style="color:#000080;background-color:#ffffff;">new</span><span style="background-color:#ffffff;"> Hashtable (</span><span style="color:#0000ff;background-color:#ffffff;">10</span><span style="background-color:#ffffff;">);
    </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">JspCal </span><span style="background-color:#ffffff;">= </span><span style="color:#000080;background-color:#ffffff;">new</span><span style="background-color:#ffffff;"> JspCalendar ();
    </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">date </span><span style="background-color:#ffffff;">= </span><span style="color:#660e7a;background-color:#ffffff;">JspCal.</span><span style="background-color:#ffffff;">getCurrentDate ();
  }

  </span><span style="color:#000080;background-color:#ffffff;">public</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">void</span><span style="background-color:#ffffff;"> setName (String nm) {
    </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">name </span><span style="background-color:#ffffff;">= nm;
  }

  </span><span style="color:#000080;background-color:#ffffff;">public</span><span style="background-color:#ffffff;"> String getName () {
    </span><span style="color:#000080;background-color:#ffffff;">return</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">name;
</span><span style="background-color:#ffffff;">  }

  </span><span style="color:#000080;background-color:#ffffff;">public</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">void</span><span style="background-color:#ffffff;"> setEmail (String mail) {
    </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">email </span><span style="background-color:#ffffff;">= mail;
  }

  </span><span style="color:#000080;background-color:#ffffff;">public</span><span style="background-color:#ffffff;"> String getEmail () {
    </span><span style="color:#000080;background-color:#ffffff;">return</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">email;
</span><span style="background-color:#ffffff;">  }

  </span><span style="color:#000080;background-color:#ffffff;">public</span><span style="background-color:#ffffff;"> String getDate () {
    </span><span style="color:#000080;background-color:#ffffff;">return</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">date;
</span><span style="background-color:#ffffff;">  }

  </span><span style="color:#000080;background-color:#ffffff;">public</span><span style="background-color:#ffffff;"> Entries getEntries () {
    </span><span style="color:#000080;background-color:#ffffff;">return</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">entries;
</span><span style="background-color:#ffffff;">  }

  </span><span style="color:#000080;background-color:#ffffff;">public</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">void</span><span style="background-color:#ffffff;"> processRequest (HttpServletRequest request) {

    </span><span style="color:#808080;background-color:#ffffff;">// Get the name and e-mail.
</span><span style="background-color:#ffffff;">    </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">processError </span><span style="background-color:#ffffff;">= </span><span style="color:#000080;background-color:#ffffff;">false</span><span style="background-color:#ffffff;">;
    </span><span style="color:#000080;background-color:#ffffff;">if</span><span style="background-color:#ffffff;"> (</span><span style="color:#660e7a;background-color:#ffffff;">name </span><span style="background-color:#ffffff;">== </span><span style="color:#000080;background-color:#ffffff;">null</span><span style="background-color:#ffffff;"> || </span><span style="color:#660e7a;background-color:#ffffff;">name.</span><span style="background-color:#ffffff;">equals(</span><span style="color:#008000;background-color:#ffffff;">""</span><span style="background-color:#ffffff;">)) setName(request.getParameter (</span><span style="color:#008000;background-color:#ffffff;">"name"</span><span style="background-color:#ffffff;">));
    </span><span style="color:#000080;background-color:#ffffff;">if</span><span style="background-color:#ffffff;"> (</span><span style="color:#660e7a;background-color:#ffffff;">email </span><span style="background-color:#ffffff;">== </span><span style="color:#000080;background-color:#ffffff;">null</span><span style="background-color:#ffffff;"> || </span><span style="color:#660e7a;background-color:#ffffff;">email.</span><span style="background-color:#ffffff;">equals(</span><span style="color:#008000;background-color:#ffffff;">""</span><span style="background-color:#ffffff;">)) setEmail(request.getParameter (</span><span style="color:#008000;background-color:#ffffff;">"email"</span><span style="background-color:#ffffff;">));
    </span><span style="color:#000080;background-color:#ffffff;">if</span><span style="background-color:#ffffff;"> (</span><span style="color:#660e7a;background-color:#ffffff;">name </span><span style="background-color:#ffffff;">== </span><span style="color:#000080;background-color:#ffffff;">null</span><span style="background-color:#ffffff;"> || </span><span style="color:#660e7a;background-color:#ffffff;">email </span><span style="background-color:#ffffff;">== </span><span style="color:#000080;background-color:#ffffff;">null</span><span style="background-color:#ffffff;"> ||
        </span><span style="color:#660e7a;background-color:#ffffff;">name.</span><span style="background-color:#ffffff;">equals(</span><span style="color:#008000;background-color:#ffffff;">""</span><span style="background-color:#ffffff;">) || </span><span style="color:#660e7a;background-color:#ffffff;">email.</span><span style="background-color:#ffffff;">equals(</span><span style="color:#008000;background-color:#ffffff;">""</span><span style="background-color:#ffffff;">)) {
      </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">processError </span><span style="background-color:#ffffff;">= </span><span style="color:#000080;background-color:#ffffff;">true</span><span style="background-color:#ffffff;">;
      </span><span style="color:#000080;background-color:#ffffff;">return</span><span style="background-color:#ffffff;">;
    }

    </span><span style="color:#808080;background-color:#ffffff;">// Get the date.
</span><span style="background-color:#ffffff;">    String dateR = request.getParameter (</span><span style="color:#008000;background-color:#ffffff;">"date"</span><span style="background-color:#ffffff;">);
    </span><span style="color:#000080;background-color:#ffffff;">if</span><span style="background-color:#ffffff;"> (dateR == </span><span style="color:#000080;background-color:#ffffff;">null</span><span style="background-color:#ffffff;">) </span><span style="color:#660e7a;background-color:#ffffff;">date </span><span style="background-color:#ffffff;">= </span><span style="color:#660e7a;background-color:#ffffff;">JspCal.</span><span style="background-color:#ffffff;">getCurrentDate ();
    </span><span style="color:#000080;background-color:#ffffff;">else</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">if</span><span style="background-color:#ffffff;"> (dateR.equalsIgnoreCase(</span><span style="color:#008000;background-color:#ffffff;">"next"</span><span style="background-color:#ffffff;">)) </span><span style="color:#660e7a;background-color:#ffffff;">date </span><span style="background-color:#ffffff;">= </span><span style="color:#660e7a;background-color:#ffffff;">JspCal.</span><span style="background-color:#ffffff;">getNextDate ();
    </span><span style="color:#000080;background-color:#ffffff;">else</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">if</span><span style="background-color:#ffffff;"> (dateR.equalsIgnoreCase(</span><span style="color:#008000;background-color:#ffffff;">"prev"</span><span style="background-color:#ffffff;">)) </span><span style="color:#660e7a;background-color:#ffffff;">date </span><span style="background-color:#ffffff;">= </span><span style="color:#660e7a;background-color:#ffffff;">JspCal.</span><span style="background-color:#ffffff;">getPrevDate ();

    </span><span style="color:#660e7a;background-color:#ffffff;">entries </span><span style="background-color:#ffffff;">= (Entries) </span><span style="color:#660e7a;background-color:#ffffff;">table.</span><span style="background-color:#ffffff;">get (</span><span style="color:#660e7a;background-color:#ffffff;">date)</span><span style="background-color:#ffffff;">;
    </span><span style="color:#000080;background-color:#ffffff;">if</span><span style="background-color:#ffffff;"> (</span><span style="color:#660e7a;background-color:#ffffff;">entries </span><span style="background-color:#ffffff;">== </span><span style="color:#000080;background-color:#ffffff;">null</span><span style="background-color:#ffffff;">) {
      </span><span style="color:#660e7a;background-color:#ffffff;">entries </span><span style="background-color:#ffffff;">= </span><span style="color:#000080;background-color:#ffffff;">new</span><span style="background-color:#ffffff;"> Entries ();
      </span><span style="color:#660e7a;background-color:#ffffff;">table.</span><span style="background-color:#ffffff;">put (date, entries);
    }

    </span><span style="color:#808080;background-color:#ffffff;">// If time is provided add the event.
</span><span style="background-color:#ffffff;">    String time = request.getParameter(</span><span style="color:#008000;background-color:#ffffff;">"time"</span><span style="background-color:#ffffff;">);
    </span><span style="color:#000080;background-color:#ffffff;">if</span><span style="background-color:#ffffff;"> (time != </span><span style="color:#000080;background-color:#ffffff;">null</span><span style="background-color:#ffffff;">) </span><span style="color:#660e7a;background-color:#ffffff;">entries.</span><span style="background-color:#ffffff;">processRequest (request, time);
  }

  </span><span style="color:#000080;background-color:#ffffff;">public</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">boolean</span><span style="background-color:#ffffff;"> getProcessError () {
    </span><span style="color:#000080;background-color:#ffffff;">return</span><span style="background-color:#ffffff;"> </span><span style="color:#000080;background-color:#ffffff;">this</span><span style="background-color:#ffffff;">.</span><span style="color:#660e7a;background-color:#ffffff;">processError;
</span><span style="background-color:#ffffff;">  }
}





</span></pre>